package $NAMESPACE.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.ugeez.commons.base.enums.CodeEnum;

public enum XXXEnum implements CodeEnum {
    KEY1(1, "key-1"),
    KEY2(2, "key-2");

    XXXEnum(int code, String value) {
        this.code = code;
        this.value = value;
    }

    private int code;
    private String value;

    @JsonValue
    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static XXXEnum valueOf(int code) {
        switch (code) {
            case 1:
                return KEY1;
            case 2:
                return KEY2;
            default:
                return null;
        }
    }
}

